<template>
	<view v-if="pageShow">
		<u-navbar placeholder>
			<view class="xiaohui" slot="left">
				<view class="flexleft" style="padding-right: 30rpx;">
					<view class="margin_right3" @click="backpage">
						<u-icon name="arrow-left" color="#000" size="24"></u-icon>
					</view>
					<view class="flexleft margin_right">
						<!-- 工程沒有内用 -->
						<view class="margin_right1" v-if="hy_type!=5" :class="type==2?'topcheck':'topnocheck'" @click="changeny(2)">内用
						</view>
						<view :class="type==1?'topcheck':'topnocheck'" @click="type=1">自取</view>
					</view>
					<template v-if="type==2 && shoptable_id">
						<view class="huang_text margin_right">{{returnycNum(khlxlist)}}人</text>
						</view>
						<view class="hei_text">{{shoptable_name}}</view>
					</template>
				</view>
			</view>
			<view class="flexright xiaohui" slot="right">
				<view class="qxbtn margin_right1" v-if="!editflag" @click="reset">重置</view>
				<view class="qxbtn margin_right1" @click="kaiqianx">開錢箱</view>
				<view class="qxbtn margin_right1">折扣</view>
				<view class="qxbtn" @click="jumpurl('/pages/workbench/zhuotaigl?type=1')">桌台</view>
			</view>
		</u-navbar>
		<view class="flexleft" style="background-color: #f0f0f0;">
			<view class="ffffff" style="width: 17%;box-sizing: border-box;padding: 10rpx;" :style="dbfstyle">
				<view class="flexbetween" style="border: 1rpx solid #fbb826; padding: 5rpx 10rpx;border-radius: 10rpx;">
					<input type="text" placeholder="請輸入搜索内容" :class="{'highlight': true}" class="xiaohei"
						:focus="inputfocus" @bulr="searchbulr" :auto-focus="hy_type==6?true:false" v-model="name"
						@confirm="searchconfirm();init()" confirm-type="search" />
					<view class="" @click="jumpurl('/pages/goodsOrder/saomagmpos?pos=1')">
						<u-icon name="scan" color="#fbb826" size="22"></u-icon>
					</view>
				</view>
				<!-- 分类导航 -->
				<scroll-view scroll-x="true" style="height: 50rpx">
					<view class="flexleft margin_top1">
						<view class="flexleft hei_text titletext" v-for="(item,index) in topList" :key="index">
							<text class="margin_right1" style="white-space: nowrap;"
								@click="back(item,index)">{{item.name}}</text>
							<view class="arrowright1" v-show="index!=topList.length-1"></view>
						</view>
					</view>
				</scroll-view>
				<!-- 分类 -->
				<scroll-view scroll-y="true" :style="onestyle">
					<view class="leftclass hei_text xiahuaxian flexbetween" v-for="item in catedata" :key="item.id"
						@click="classLableClick(item)">
						<view class="xiaohei" style="font-size: 32rpx;">{{item.name}}</view>
						<u-icon name="arrow-right" color="#fbb826" size="14" v-if="item.is_haschild"></u-icon>
					</view>
				</scroll-view>
			</view>
			<view style="width: 60%;box-sizing: border-box;padding: 0 10rpx 10rpx 10rpx;" :style="dbfstyle">
				<!-- 商品列表 -->
				<view class="" style="height: 55%;">
					<scroll-view scroll-y="true" style="height: 100%;" @scrolltolower="onReachBottomt">
						<view class="flexleft flex-wrap" style="width: 100%;">
							<view class="flexcenter" style="width: 20%;padding-top: 10rpx;" v-for="item in list.data"
								:key="item.id" @click="changegoods(item.id)">
								<view class="itemgoods flexcolumn" :style="[{ backgroundColor: item.font_color }]" style="width: 95%;"
									:class="listid == item.id?'itemcheckgoods':''">
									<view class="goodsname hei_text textcenter flexcenter sanhang">{{item.name}}
									</view>
									<view class="textcenter hei_text" style="font-size: 26rpx;">${{item.new_price}}
									</view>
								</view>
							</view>
						</view>
					</scroll-view>
				</view>
				<!-- 数量 -->
				<view class="" style="height: 8%;">
					<view class="flexleft" style="height: 100%;padding-top: 10rpx;">
						<view class="flexcenter margin_right3" :class="index+1==num?'numbox':'nonumbox'"
							v-for="(item,index) in 10" @click="num = index+1;">{{index+1}}</view>
						<view class="numbox flexcenter margin_right" @click="numshow=true">
							<u-icon name="fingerprint" color="#fff" size="14"></u-icon>
						</view>
					</view>
				</view>
				<!-- 商品规格2 -->
				<view class="" style="height: 37%;">
					<scroll-view class="margin_top1" scroll-y="true" style="height: 100%;" v-if="listid!=''">
						<view class="" v-for="(item,index) in spuList" :key="item.id">
							<scroll-view scroll-x="true" style="width: 100%;">
								<view class="flexleft" style="align-items: flex-start;">
									<view class="margin_right1" style="padding-top: 10rpx;">
										<view class="itemboxcenter" :style="[{ backgroundColor: item.font_color }]">
											<view class="hei_text flexcenter main_size bold"
												style="font-size: 28rpx;min-width: 80rpx;white-space: nowrap;">
												{{item.name}}
											</view>
											<text class="main_size flexcenter margin_right1"
												style="font-size: 24rpx;">{{item.fh==1?'=':'>'}}{{item.num_b}}</text>
										</view>
									</view>
									<view class="margin_right1" v-for="(value,i) in item.list" :key="value.id"
										@click="checkgger(item,value)" style="padding-top: 10rpx;">
										<view class="itemboxcenter" :style="[{ backgroundColor: value.num==1?'#d3e3fd':item.font_color }]">
											<view class="hei_text flexcenter main_size bold"
												style="font-size: 28rpx;min-width: 80rpx;white-space: nowrap;">
												{{value.name}}
											</view>
											<text class="main_size flexcenter margin_right1"
												style="font-size: 24rpx;">+{{value.money}}</text>
										</view>
									</view>
								</view>
							</scroll-view>
						</view>
					</scroll-view>
				</view>
			</view>
			<view class="" style="width: 23%;box-sizing: border-box;" :style="dbfstyle">
				<!-- 购物车列表 -->
				<view class="" style="height: 100%;">
					<view class="" style="height: 86%;">
						<scroll-view scroll-y="true" style="height: 100%;">
							<view class="" style="padding: 10rpx;">
								<view class="flexleft ffffff" :class="rightclassIndex==index?'itemcheckgoods':''"
									v-for="(item,index) in goodsdata" :key="index" @click="editgoods(item,index)">
									<view class="justify_between_column" style="width: 100%;">
										<view class="hei_text titletext bold">{{item.goods_name}}</view>
										<view class=" flexleft flex-wrap">
											<view class="lanlable xmargin_top" v-for="(ite,ind) in item.spunatdata"
												:key="ind">
												{{ite.spunatname}}
											</view>
										</view>
										<view class="flexbetween ">
											<view class="huang_text bold titletext">
												+{{item.d_price}}&nbsp;&nbsp;&nbsp;x{{item.num}}
											</view>
											<view class="flexright">
												<view class="huang_text titletext margin_right1">${{item.price}}</view>
												<view @click="delcarts(index)">
													<u-icon name="trash" color="#333" size="20"></u-icon>
												</view>
											</view>
										</view>
									</view>
								</view>
								<view class="flexleft ffffff" v-for="item in khlxlist" :key="item.id"
									v-if="item.num!=0 && item.price!=0 && type==2">
									<view class="justify_between_column" style="width: 100%;">
										<view class="hei_text titletext bold">{{item.name}}</view>
										<view class="flexbetween ">
											<view class="huang_text bold titletext">
												+{{item.price}}&nbsp;&nbsp;&nbsp;x{{item.num}}
											</view>
											<view class="huang_text titletext margin_right1">${{item.price*item.num}}
											</view>
										</view>
									</view>
								</view>
								<template v-if="editflag">
									<view class="hei_text titletext bold margin_top1">已點商品</view>
									<view class="margin_top1"></view>
									<view class="flexleft ffffff" v-for="(item,index) in orderInfo.goods_data"
										:key="index">
										<view class="justify_between_column" style="width: 100%;">
											<view class="hei_text titletext bold">{{item.goods_name}}</view>
											<view class=" flexleft flex-wrap">
												<view class="lanlable xmargin_top"
													v-for="(ite,ind) in item.spunatdata_text" :key="ind">
													{{ite.spunatname}}
												</view>
											</view>
											<view class="flexbetween ">
												<view class="huang_text bold titletext">
													+{{item.d_price}}&nbsp;&nbsp;&nbsp;x{{item.num}}
												</view>
												<view class="huang_text titletext margin_right1">${{item.price}}</view>
											</view>
										</view>
									</view>
									<view class="flexleft ffffff" v-for="item in orderInfo.cdbjhsf_data" :key="item.id"
										v-if="item.num!=0 && item.price!=0">
										<view class="justify_between_column" style="width: 100%;">
											<view class="hei_text titletext bold">{{item.name}}</view>
											<view class="flexbetween ">
												<view class="huang_text bold titletext">
													+{{item.price}}&nbsp;&nbsp;&nbsp;x{{item.num}}
												</view>
												<view class="huang_text titletext margin_right1">
													${{item.price*item.num}}
												</view>
											</view>
										</view>
									</view>
								</template>
							</view>
						</scroll-view>
					</view>
					<view class="dingwei" style="height: 14%;">
						<view class="flexbetween" style="position: absolute;bottom: 0;width: 100%;">
							<view class="ffffff" style="padding: 20rpx;width: 70%;">
								<view class="flexleft" @click="pricemx=true">
									<view style="rotate: 90deg;">
										<u-icon name="arrow-left-double" color="#999" size="18"></u-icon>
									</view>
									<view class="hei_text main_size">合計:</view>
									<view class="huang_text main_size" style="font-size: 36rpx;" v-text="totalPrice">
									</view>
								</view>
							</view>
							<view class="xiaobai"
								style="padding: 20rpx;background-color: #e58701;width: 30%;font-size: 36rpx;">
								<view class="textcenter" @click="shoukuanbtn">結帳</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 发票输入 -->
		<u-modal :show="fpisshow" title="請輸入發票號碼" class="fpclass" confirmColor="#fbb826" confirmText="確定"
			cancelText="關閉" showCancelButton @cancel="fpisshow=false" @confirm="fpconfirm">
			<view class="slot-content ">
				<view class="mainpadding2 " style="padding-bottom: 0;">
					<view class="flexbetween"
						style="border: 1rpx solid #fbb826; padding: 10rpx 20rpx;border-radius: 10rpx;">
						<input type="text" placeholder="" disabled="" class="xiaohei" :focus="fpinputfocus"
							:auto-focus="true" v-model="tbcode" confirm-type="search" />
						<view @click="getCode">
							<u-icon name="scan" color="#fbb826" size="22"></u-icon>
						</view>
					</view>
					<view class="flexcenter">
						<view class="flexbetween flex-wrap" style="width: 100%;">
							<view class="itemboxfp flexcenter" v-for="item in numList" :key="item"
								@click="numtapfp(item)">
								{{item}}
							</view>
							<view class="itemboxfp delitem flexcenter" @click="delnumfp">DEL</view>
						</view>
					</view>
				</view>
			</view>
		</u-modal>
		<!-- 支付選擇支付方式彈框 -->
		<u-popup :show="show" @close="show=false;rall_ids=''" round="30" mode="center" closeable>
			<view class="">
				<view class="titletext flexleft" v-if="appkey && is_pos_sdkfp==0 && opentype!=-1"
					style="position: relative;top: 20rpx;left: 30rpx;">
					<!-- 0紙本，1載具，2統編，3捐贈 -->
					<text>{{returnfptext(opentype)}}</text>
					<text>{{tbcode}}</text>
					<text v-show="opentype==2 && tbmc">【{{tbmc}}】</text>
					<view class="flexbetween"
						style="border: 1rpx solid #fbb826; padding: 5rpx 20rpx;border-radius: 10rpx;margin-left: 30rpx;">
						<input type="text" placeholder="優惠券" style="width: 200rpx;" class="xiaohei" v-model="yhqurl"
							@confirm="searchyhq" confirm-type="search" />
						<view class="" @click="dssaoma()">
							<u-icon name="scan" color="#fbb826" size="22"></u-icon>
						</view>
					</view>
				</view>
				<view class="mainpadding flexleft" style="align-items: flex-start;">
					<view class="flexcolumnbet" style="width: 240rpx;height: 300px;">
						<view class="" style="width: 100%;">
							<view class="xiaohei textcenter margin_top main_size bold qxbtn"
								style="margin-right: 30rpx;padding: 5rpx;">消費明細</view>
							<view class="flexbetween margin_top main_size" style="margin-right: 30rpx;">
								<view class="hui_text">商品金額</view>
								<view class="xiaohong">${{goodsprice}}</view>
							</view>
							<view class="flexbetween margin_top1 main_size" style="margin-right: 30rpx;">
								<view class="hui_text">服務費</view>
								<view class="xiaohong">${{fwprice}}</view>
							</view>
							<view class="flexbetween margin_top1 main_size " style="margin-right: 30rpx;"
								v-if="type==2">
								<view class="hui_text">主商品<text class="hong_text">{{reduceMainNum}}</text>个，桌位費</view>
								<view class="xiaohong">${{zwprice}}</view>
							</view>
							<view class="flexbetween margin_top1 main_size pdl" style="margin-right: 30rpx;">
								<view class="hui_text">優惠金額</view>
								<view class="xiaohong">-${{dkprice}}</view>
							</view>
							<view class="flexbetween margin_top1 main_size" style="margin-right: 30rpx;">
								<view class="hui_text">合計</view>
								<view class="xiaohong">${{totalPrice - dkprice}}</view>
							</view>
							<view class="flexbetween margin_top1 main_size" style="margin-right: 30rpx;">
								<view class="hui_text">實收金額</view>
								<view class="xiaohong">${{zhifuje || 0}}</view>
							</view>
						</view>
						<view class="margin_top">
							<view class="bold hei_text" style="font-size: 32rpx;">應找金額：</view>
							<view class="bold xiaohong" style="font-size: 52rpx;" v-text="zhaoling"></view>
						</view>
					</view>
					<view class="margin_right" style="width: 430rpx;">
						<view class="flexbetween flex-wrap">
							<view class="itembox flexcenter" v-for="item in numList" :key="item" @click="numtap(item)">
								{{item}}
							</view>
							<view class="itembox delitem flexcenter" @click="delnum">DEL</view>
						</view>
						<view class="flexbetween margin_top1">
							<view class="flexcenter qxbtn" style="width: 100rpx;background-color: #95D5F6;color: #333;"
								v-for="item in numList2" :key="item" @click="numtap(item)">
								{{item}}
							</view>
						</view>
					</view>
					<view class="flexcolumn margin_right">
						<view class="payTypeClass xiaobai" style="background-color: #00a0e9;" @click="submit(4)">信用卡
						</view>
						<view class="payTypeClass margin_top2 xiaobai" style="background-color: #ec7301;"
							@click="dypay">多元支付
						</view>
						<view class="payTypeClass margin_top2 xiaobai" style="background-color: #db0f62;"
							@click="submit(1)">錢包點數
						</view>
						<view class="payTypeClass margin_top2 xiaobai" style="background-color: #a70182;"
							@click="submit(3)">現金支付
						</view>
					</view>
					<view class="flexcolumn">
						<view class="radius margin_top1" style="background-color: #fbf6f1;padding: 10rpx;"
							v-for="item in yhqList" :key="item.id">
							<view class="flexleft ">
								<view class="margin_right2">
									<view class="huang_text titletext bold">${{item.dk_money}}</view>
									<view class="hui_text main_size  bold">滿{{item.di_money}}可用</view>
								</view>
								<view>
									<view class="hei_text titletext bold">{{item.name}}</view>
									<view class=" hui_text main_size bold">有效期至{{http.returnDate(item.endtime*1000)}}
									</view>
								</view>
							</view>
						</view>
					</view>

				</view>
			</view>
		</u-popup>
		<!-- 多元掃碼支付 -->
		<u-modal :show="dymodalshow" title="請使用掃描器掃描" confirmColor="#fbb826" confirmText="關閉"
			@confirm="dymodalshow=false;issubmit=false">
			<view class="slot-content">
				<view class="mainpadding">
					<view class="flexbetween"
						style="border: 1rpx solid #fbb826; padding: 10rpx 20rpx;border-radius: 10rpx;">
						<input type="text" readonly placeholder="" class="xiaohei" :focus="dyinputfocus"
							:auto-focus="true" v-model="dycode" inputmode="none" @confirm="dykoukuan"
							confirm-type="search" />
						<view class="" @click="dysaoma()">
							<u-icon name="scan" color="#fbb826" size="22"></u-icon>
						</view>
					</view>
				</view>
			</view>
		</u-modal>
		<!-- 點數掃碼支付 -->
		<u-modal :show="dsmodalshow" title="請使用掃描器掃描" confirmColor="#fbb826" confirmText="關閉"
			@confirm="dsmodalshow=false;issubmit=false">
			<view class="slot-content">
				<view class="mainpadding">
					<view class="flexbetween"
						style="border: 1rpx solid #fbb826; padding: 10rpx 20rpx;border-radius: 10rpx;">
						<input type="text" inputmode="none" readonly placeholder="" class="xiaohei"
							:focus="dsinputfocus" :auto-focus="true" v-model="dscode" @confirm="dskoukuan"
							confirm-type="search" />
						<view class="" @click="dssaoma()">
							<u-icon name="scan" color="#fbb826" size="22"></u-icon>
						</view>
					</view>
				</view>
			</view>
		</u-modal>
		<!-- 更改商品數量 -->
		<u-modal :show="numshow" title="輸入購買數量" confirmColor="#fbb826" confirmText="關閉" @confirm="numshow=false">
			<view class="slot-content">
				<view class="mainpadding">
					<view class="flexbetween"
						style="border: 1rpx solid #fbb826; padding: 10rpx 20rpx;border-radius: 10rpx;">
						<input type="text" placeholder="" class="xiaohei" v-model="num" @confirm="numshow=false"
							confirm-type="search" />
					</view>
				</view>
			</view>
		</u-modal>
		<!-- 合計明細 -->
		<u-modal :show="pricemx" title="合計明細" confirmColor="#fbb826" confirmText="關閉" @confirm="pricemx=false">
			<view class="slot-content" style="width: 100%;">
				<view class="mainpadding">
					<view class="flexbetween  bold main_size">
						<view class="xiaohei">商品金額</view>
						<view class="xiaohong">${{goodsprice}}</view>
					</view>
					<view class="flexbetween margin_top bold main_size">
						<view class="xiaohei">服務費</view>
						<view class="xiaohong">${{fwprice}}</view>
					</view>
					<view class="flexbetween margin_top bold main_size " v-if="type==2">
						<view class="xiaohei">主商品<text class="xiaohong">{{reduceMainNum}}</text>个，桌位費</view>
						<view class="xiaohong">${{zwprice}}</view>
					</view>
					<view class="flexbetween margin_top bold main_size">
						<view class="xiaohei">合計</view>
						<view class="xiaohong">${{totalPrice}}</view>
					</view>
				</view>
			</view>
		</u-modal>
		<u-modal :show="nyshow" title="輸入内用信息" confirmColor="#fbb826" confirmText="確定" showCancelButton
			@cancel="nyshow=false" @confirm="nyconfirm" cancelText="關閉">
			<view class="margin_top1 ffffff radius">
				<view class="flexbetween">
					<view class="titletext bold hei_text white_nowrap">客戶行動電話</view>
					<input class="main_size bold hei_text textright" type="number" placeholder="請輸入" v-model="phone">
				</view>
				<scroll-view scroll-y="true" style="height: 350rpx;">
					<view class="flexbetween margin_top" v-for="item in khlxlist" :key="item.id">
						<view class="titletext bold hei_text white_nowrap">{{item.name}}</view>
						<view class="flexright">
							<text class="xiaohuang margin_right1">${{item.price}}</text>
							<view class="flexbetween bghui radius" style="padding: 10rpx;">
								<view class="reduceimg" @click="reduceFn(item)"></view>
								<input type="number" style="width: 100rpx; text-align: center;" v-model="item.num">
								<view class="addimg" @click="addFn(item)"></view>
							</view>
						</view>
					</view>
				</scroll-view>
			</view>
		</u-modal>
		<fukuanmsg :show="messagefk.fkshow" :paystatus="messagefk.paystatus"></fukuanmsg>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				numshow: false,
				pricemx: false, //合計明細彈框
				zwprice: 0, //桌位金額
				goodsprice: 0, //商品金額
				fwrotate: 0, //服務費比例
				fwprice: 0, //服務費
				yhqurl: "", //優惠券鏈接
				dkprice: 0, //抵扣金額
				rall_ids: "",
				yhqList: [],
				num: 1,
				hy_type: 0, //行业类型:0=无,1=吃到饱,2=诊所,3=住宿,4=租借,5工程，6超商
				pid: 0, //当前分类id
				catedata: [],
				topList: [],
				topList: [{
					name: "首頁",
					id: 0
				}], //顶部展示列表
				name: "",
				page: 1,
				list: {
					data: []
				},
				listid: "",
				is_df: 0,
				goodsInfo: {
					goods_sale: []
				},
				spuList: [], //商品规格二列表
				// weiDisabled: false,
				heiDisabled: true,
				shop_id: uni.getStorageSync("shop_id"),
				wei: "", //宽
				hei: "", //高
				spunatname: "", //规格2属性名称
				spunatid: "", //规格2属性id
				addimage: [], //上传的图片
				addimage_arr: [], //上传的图片展示
				formulaValue: 1, //公式算出来的值
				notes: "", //备注
				secondList: [], //二级商品列表
				selectSpuNum: [], //商品规格2已選擇的规格属性数量
				djprice: 0,
				clxz_id: "", //处理選擇的id
				clxzj_value: "", //处理選擇的計算值
				//处理選擇
				clshow: false,
				sp_attr: [],
				rightArr: [],
				goodsdata: [],
				inputfocus: false,
				type: 1, //1自取，2内用
				messagefk: {
					fkshow: false,
					paystatus: 1, //1成功，2失败
				},
				fpisshow: false,
				fpinputfocus: false,
				appkey: "",
				is_pos_sdkfp: 0,
				tbcode: "",
				tbmc: "",
				opentype: -1,
				orderly: 0,
				show: false,
				zhifuje: "",
				numList: [7, 8, 9, 4, 5, 6, 1, 2, 3, "00", 0],
				numList2: [50, 100, 500, 1000],
				dymodalshow: false,
				dyinputfocus: false,
				dycode: "",
				dscode: "",
				dsinputfocus: false,
				dsmodalshow: false,
				goods_list_ids: [],
				order_id: "",
				rightclassIndex: 0,
				// 内用信息
				shoptable_id: 0,
				shoptable_name: "",
				ztJump: 0, //是否剛剛從使用管理跳轉過來
				editflag: false, //是否是編輯内容
				phone: "", //客户行动电话
				nyshow: false,
				ztNum: 0,
				winInnerHeight: 0,
				pageShow: false,
				jx: '',
				czjx: "",
				khlxlist: [],
				shopInfo: {},
				orderInfo: {},
				issubmit: false,
				reduceMainNum: 0,
				reduceMainprice: 0
			}
		},
		onLoad(options) {
			if (options.id) { //從桌臺進來直接開桌
				this.type = 2
				this.nyshow = true
				this.editflag = false
				this.ztJump = 1
				this.shoptable_id = options.id
				this.shoptable_name = options.name
			}
			this.getOS()
			setTimeout(() => {
				this.pageShow = true
			}, 50)
			this.winInnerHeight = window.innerHeight;
			if (process.env.VUE_APP_PLATFORM === 'h5') {
				window.addEventListener('resize', this.handleResize);
			}
			this.appkey = uni.getStorageSync("appkey")
			this.is_pos_sdkfp = uni.getStorageSync("is_pos_sdkfp")
			uni.$on("returnCode", data => {
				this.tbcode = data
			})
			uni.$on("scangoodsid", data => {
				this.jumpdetail(data)
			})
			uni.$on("possacnCode", data => {
				this.dycode = data
				this.dykoukuan()
			})
			uni.$on("getpayscancode", data => {
				if (this.dymodalshow && data) {
					this.dycode = data
					this.dykoukuan()
				}
			})
			uni.$on("poscheckTab", data => {
				this.shoptable_id = data.id
				this.shoptable_name = data.name
			})
			uni.$on("poscheckTab2", data => {
				this.type = 2
				this.nyshow = true
				this.editflag = false
				this.ztJump = 1
				this.shoptable_id = data.id
				this.shoptable_name = data.name
			})
			// 編輯桌臺訂單信息
			uni.$on("editTaborder", data => {
				this.type = 2
				this.editflag = true
				this.order_id = data.order_goods_id
				this.ztJump = 1
				this.shoptable_id = data.id
				this.shoptable_name = data.name
				this.getorderInfo()
			})
			this.hy_type = uni.getStorageSync("hy_type")
			this.getCateList()
			this.init()
			this.getztnum()
			this.getkhlx()
			this.getShopInfo()
		},
		onUnload() {
			uni.$off("returnCode")
			uni.$off("scangoodsid")
			uni.$off("possacnCode")
			uni.$off("poscheckTab")
			uni.$off("poscheckTab2")
			uni.$off("editTaborder")
			uni.$off("getpayscancode")
			if (process.env.VUE_APP_PLATFORM === 'h5') {
				window.removeEventListener('resize', this.handleResize);
			}
		},
		watch: {
			dymodalshow(newval) {
				if (!newval) {
					this.dycode = ""
				}
			},
			spuList: {
				deep: true,
				handler(newval) {
					let arr = []
					newval.forEach(item => {
						item.list.forEach(ite => {
							if (ite.num > 0) {
								arr.push(ite)
							}
						})
					})
					this.rightArr = arr
				}
			},
			clxz_id: {
				handler(newval) {
					if (this.clxz_id == "" && this.goodsInfo.is_cl == 1) {
						this.clshow = true
					}
				},
				deep: true
			},
			num: {
				handler(newVal) {
					if (this.goodsInfo.goods_sale.length && this.clxz_id == "") {
						let arr = []
						this.goodsInfo.goods_sale[this.is_df].sale_money.forEach(item => {
							if (Number(item.js_num) <= Number(this.formulaValue * this.num)) {
								arr.push(item.d_money)
							}
						})
						if (arr.length) {
							this.djprice = arr[0]
						} else {
							this.djprice = this.goodsInfo.goods_sale[this.is_df].sale_money[0].d_money
						}
					}
					this.goodsdata[this.rightclassIndex].num = newVal
					this.goodsdata[this.rightclassIndex].d_price = this.djprice
					let price = 0
					this.spuList.forEach(item => {
						item.list.forEach(value => {
							if (value.num) {
								price = Number(price) + Number(value.money) * value.num
							}
						})
					})
					price = (this.djprice * this.num + price)
					if (this.goodsdata.length) {
						this.goodsdata[this.rightclassIndex].price = price
					}
				},
				deep: true
			},
			is_df: {
				handler(newval) {
					if (this.goodsInfo.is_cl == 0) {
						if (this.goodsInfo.goods_sale.length && this.clxz_id == "") {
							this.djprice = this.goodsInfo.goods_sale[this.is_df].sale_money[0].d_money
						}
					} else {
						this.clxz_id = ""
						this.clxzj_value = ""
					}
					this.goodsdata[this.rightclassIndex].d_price = this.djprice
				},
				deep: true
			},
			formulaValue: {
				handler(newval) {
					if (this.goodsInfo.goods_sale.length && this.clxz_id == "") {
						let arr = []
						this.goodsInfo.goods_sale[this.is_df].sale_money.forEach(item => {
							if (Number(item.js_num) <= Number(newval * this.num)) {
								arr.push(item.d_money)
							}
						})
						if (arr.length) {
							this.djprice = arr[0]
						} else {
							this.djprice = this.goodsInfo.goods_sale[this.is_df].sale_money[0].d_money
						}
					}
					this.goodsdata[this.rightclassIndex].d_price = this.djprice
				},
				deep: true
			},
			wei(newVal) {
				if (newVal) {
					this.heiDisabled = false
				}
			},
			goodsdata: {
				deep: true,
				handler(newval) {
					this.getreduceMainprice()
				}
			},
			khlxlist: {
				deep: true,
				handler(newval) {
					this.getreduceMainprice()
				}
			},
			type(newval) {
				this.getreduceMainprice()
			}
		},
		computed: {
			dbfstyle() {
				return {
					height: this.jx == 'ios' ? this.winInnerHeight - 45 + 'px' : 'calc(100vh - 45px)'
				}
			},
			onestyle() {
				return {
					height: this.jx == 'ios' ? this.winInnerHeight - 105 + 'px' : 'calc(100vh - 105px)'
				}
			},
			zhaoling() {
				let price = Number(this.zhifuje) - Number(this.totalPrice) + Number(this.dkprice)
				if (price >= 0) {
					return price
				} else {
					return 0
				}
			},
			totalPrice() {
				let price = 0 //總價
				let zwprice = 0
				this.goodsdata.forEach(item => {
					price = Number(item.price) + Number(price)
				})
				this.goodsprice = price //商品價格
				if (this.type == 2) {
					this.khlxlist.forEach(item => {
						price = Number(item.price) * item.num + Number(price)
						zwprice = Number(item.price) * item.num + Number(zwprice)
					})
				}
				zwprice = Number(zwprice) - Number(this.reduceMainprice)
				this.zwprice = zwprice //座位費
				if (this.type == 2) { //自取存在服務費
					this.fwprice = Math.round(price * this.fwrotate / 100) //服務費
					price = price + Math.round(price * this.fwrotate / 100)
				} else {
					this.fwprice = 0 //服務費
				}
				price = Number(price) - Number(this.reduceMainprice)
				return price
			},
			subTotal() { //小計价格
				let end_price = 0
				let value = this.formulaValue * this.djprice * this.num
				let price_j = 0
				if (this.goodsInfo.goods_sale.length) {
					price_j = Number(this.goodsInfo.goods_sale[this.is_df].price_j)
				}
				if (value > price_j) {
					end_price = value
				} else {
					end_price = price_j
				}
				return Number(end_price).toFixed(0)
			},
			money() { //总价
				let price = 0
				this.spuList.forEach(item => {
					item.list.forEach(value => {
						if (value.num) {
							price = Number(price) + Number(value.money) * value.num
						}
					})
				})
				price = (this.djprice * this.num + price)
				return price
			}
		},
		methods: {
			getreduceMainprice() {
				let mainNum = 0 //主商品数量
				this.goodsdata.forEach(item => {
					if (item.is_main == 1) {
						mainNum = Number(mainNum) + Number(item.num)
					}
				})
				let arr = []
				let price = 0
				if (this.type == 2 && this.shopInfo.is_zdxf == 1) {
					this.khlxlist.forEach(item => {
						if (item.num != 0 && item.price != 0) {
							for (let i = 0; i < item.num; i++) {
								arr.push(Number(item.price))
							}
						}
					})
					arr.sort((a, b) => b - a);
					let arr2 = []
					for (let i = 0; i < mainNum; i++) {
						arr2.push(arr[i])
					}
					arr2.forEach(item => {
						if (item) {
							price = Number(price) + Number(item)
						}
					})
				}
				this.reduceMainNum = mainNum
				this.reduceMainprice = price
			},
			searchyhq() { //查詢優惠券
				if (this.yhqurl == "") return
				uni.showLoading({
					mask: true,
					title: "請稍後"
				})
				this.rall_ids = this.getQueryVariable('ids')
				this.http.request("/api/shop/rallAlldeail", 'POST', {
					id: this.rall_ids,
				}).then(res => {
					uni.hideLoading()
					this.yhqurl = ""
					if (res.code == 1) {
						let diprice = 0
						let dkprice = 0
						res.data.forEach(item => {
							diprice = Number(item.di_money) + diprice
							dkprice = Number(item.dk_money) + dkprice
						})
						if (this.totalPrice < diprice) {
							httpRequest.toast('當前優惠券須達到' + diprice + "才能使用")
							return false
						}
						this.dkprice = dkprice
						this.yhqList = res.data
					} else {
						httpRequest.toast(res.msg)
						this.dkprice = 0
						this.yhqList = []
					}
				})
			},
			getQueryVariable(variable) {
				var query = this.yhqurl;
				var rooms = query.split('?');
				for (var i = 0; i < rooms.length; i++) {
					var pair = rooms[i].split('=');
					if (pair[0] == variable) {
						return (pair[1].split('&'))[0]
					}
				}
				//或者拼接&後面的值
				var vars = query.split('&')
				for (var i = 0; i < vars.length; i++) {
					var pair = vars[i].split('=')
					if (pair[0] == variable) {
						return pair[1]
					}
				}
			},
			searchconfirm() {
				if (this.hy_type == 6) {
					this.inputfocus = false;
					this.$nextTick(() => {
						this.inputfocus = true;
					})
				}
			},
			getorderInfo() { //订單详情
				this.http.request('/api/Ordergoods/deailOrdergoods', 'POST', {
					id: this.order_id
				}).then(res => {
					if (res.code == 1) {
						res.data.cdbjhsf_data = JSON.parse(res.data.cdbjhsf_data)
						this.orderInfo = res.data
					}
				})
			},
			returnycNum(val) {
				let num = 0
				val.forEach(item => {
					num = Number(num) + Number(item.num)
				})
				return num
			},
			getShopInfo() {
				this.http.request("/api/shop/Shopdeail", "POST", {
					shop_id: uni.getStorageSync("shop_id"),
				}).then(res => {
					this.shopInfo = res.data
					if (new Date().getDay() == 1) this.fwrotate = this.shopInfo.motime_rate //周一
					if (new Date().getDay() == 2) this.fwrotate = this.shopInfo.tutime_rate //周二
					if (new Date().getDay() == 3) this.fwrotate = this.shopInfo.wetime_rate //周三
					if (new Date().getDay() == 4) this.fwrotate = this.shopInfo.thtime_rate //周四
					if (new Date().getDay() == 5) this.fwrotate = this.shopInfo.frtime_rate //周五
					if (new Date().getDay() == 6) this.fwrotate = this.shopInfo.satime_rate //周六
					if (new Date().getDay() == 0) this.fwrotate = this.shopInfo.sutime_rate //周日
				})
			},
			getkhlx() {
				httpRequest.request('/api/cdb/cdbjhsfIndex', 'GET', {
					shop_id: uni.getStorageSync("shop_id"),
				}).then(res => {
					if (res.code == 1) {
						res.data.forEach(item => {
							this.$set(item, "num", 0)
						})
						this.khlxlist = res.data
					}
				})
			},
			dysaoma() { //多元掃碼扣款
				uni.navigateTo({
					url: "/pages/pospay/pospay"
				})
			},
			dssaoma() { //點數掃碼扣款
				uni.navigateTo({
					url: "/pages/dianshupay/dianshupay?type=2&id=" + this.order_id
				})
			},
			getOS() {
				if (uni.getSystemInfoSync().platform == 'ios') {
					this.jx = 'ios';
				} else {
					this.jx = 'Android';
				}
				this.czjx = uni.getSystemInfoSync().platform
			},
			handleResize() {
				this.winInnerHeight = window.innerHeight;
			},
			// 内用開始
			changeny(val) {
				if (this.ztNum == 0) {
					httpRequest.toast("還未添加桌臺")
					return false
				}
				this.type = 2
				this.nyshow = true
			},
			async getztnum() { //使用列表
				let res = await this.http.request('/api/shop/listtable', 'POST', {
					shop_id: uni.getStorageSync("shop_id"),
				})
				if (res.code == 1) {
					this.ztNum = res.data.length
				} else {
					this.ztNum = 0
				}
			},
			nyconfirm() {
				let num = 0
				this.khlxlist.forEach(item => {
					num = item.num + num
				})
				if (num == 0) {
					this.http.toast("請至少填寫一個人數！")
					return false
				}
				this.nyshow = false
				if (this.ztJump != 1) {
					uni.navigateTo({
						url: "/pages/goodsOrder/poszt?num="+num
					})
				} else {
					this.ztJump = 0
				}
			},
			reduceFn(item) { //減
				if (item.num == 0) {
					return false
				}
				item.num = item.num - 1
			},
			addFn(item) { //加
				item.num = item.num + 1
			},
			// 编辑商品
			editgoods(item, index) {
				if (this.listid == item.goods_id && index == 0) {
					return false
				}
				this.getdetail(item.goods_id, true, index)
			},
			//结账逻辑
			returnfptext() {
				if (this.opentype == 0 && this.tbcode == '') return "紙本"
				if (this.opentype == 1) return "載具："
				if (this.opentype == 2) return "統編："
				if (this.opentype == 3) return "捐贈："
			},
			fpconfirm() {
				// 0紙本，1載具，2統編，3捐贈
				if (this.tbcode == "") { //紙本
					this.opentype = 0
				}
				if (this.tbcode.length == 8) { //統編
					this.opentype = 2
					this.getTt()
				}
				if (this.tbcode.length == 6) { //捐贈
					this.opentype = 3
				}
				if (this.tbcode.includes('/')) { //載具
					this.opentype = 1
				}
				this.fpisshow = false;
				this.show = true
			},
			getTt() {
				if (this.opentype != 2) {
					return false
				}
				this.http.request("/api/user/getTbmc", "GET", {
					tbcode: this.tbcode
				}).then(res => {
					if (res.code == 1) {
						this.tbmc = res.data.tbinfo.name
					} else {
						this.tbmc = ""
					}
				})
			},
			async submit(val) { //提交
				if (this.issubmit) return
				let data = {
					// zhuimoney: this.totalPrice,
					// goods_list_ids: this.goods_list_ids.join(),
					// order_goods_id: this.order_id,
					// ly: 1, //如果是预约订單提交的时候,来源传2其他情况传1
					// opentype: this.opentype,
					// tbcode: this.appkey && this.opentype != -1 ? this.tbcode : '',
					// tbmc: this.appkey && this.opentype != -1 ? this.tbmc : '',
					// order_type: 4,
					// paytype: val,
					// order_attr: 1,
					// yh_money: this.dkprice, //優惠金額
					// rall_id: this.rall_ids, //優惠券id
					id: this.order_id,
					scanpay_code: "",
					paytype: val,
					orderdata:{
						zhuimoney: this.totalPrice,
						rall_id: this.rall_ids, //優惠券id
						yh_money: this.dkprice, //優惠金額
						opentype: this.opentype,
						tbcode: this.appkey && this.opentype != -1 ? this.tbcode : '',
						tbmc: this.appkey && this.opentype != -1 ? this.tbmc : '',
					}
				}
				if (val == 1) { //点数支付走线下功能需要传这个参数
					this.$set(data, "is_scan", 2)
				}
				uni.showLoading({
					mask: true,
					title: "請稍後"
				})
				this.issubmit = true
				let res = await this.http.request('/api/ordergoods/paymentOrder', 'POST', data)
				uni.hideLoading()
				if (res.code == 1) {
					if (val == 1) { //点数支付走这里
						this.dsmodalshow = true
						this.dsinputfocus = true
					} else {
						this.http.toast("提交成功")
						setTimeout(() => {
							uni.reLaunch({
								url: "/pages/workbench/newpos"
							})
						}, 1000)
					}
				} else {
					this.issubmit = false
					this.http.toast(res.msg)
				}
			},
			async dypay(val) {
				let arr = []
				this.dymodalshow = true
				this.dyinputfocus = true
			},
			dskoukuan() { //點數掃碼槍或輸入回車扣款
				httpRequest.request("/api/pay/userMoenyScan", "POST", {
					shop_id: uni.getStorageSync("shop_id"),
					id: this.order_id,
					paycode: this.dscode,
				}).then(res => {
					httpRequest.toast(res.msg)
					if (res.code == 1) {
						this.messagefk = {
							fkshow: true,
							paystatus: 1
						}
						setTimeout(() => {
							this.messagefk = {
								fkshow: false,
								paystatus: 1
							}
							uni.reLaunch({
								url: "/pages/workbench/newpos"
							})
						}, 1000)
					} else {
						this.messagefk = {
							fkshow: true,
							paystatus: 2
						}
						setTimeout(() => {
							this.messagefk = {
								fkshow: false,
								paystatus: 2
							}
							this.dymodalshow = true
							this.dyinputfocus = true
						}, 1000)
					}
				})
			},
			async dykoukuan() { //多元掃碼槍或輸入回車扣款
				if (this.issubmit) return
				uni.showLoading({
					mask: true,
					title: "請稍後"
				})
				let val = 0 //1全支付，2icash支付，3悠悠付，7街口支付，8line pay
				if (this.dycode.substring(0, 2) == 22) val = 7
				if (this.dycode.substring(0, 2) == 38) val = 8
				if (this.dycode.substring(0, 2) == 'P1' || this.dycode.substring(0, 2) == 'P2') val = 11
				if (val == 0) {
					httpRequest.toast("付款碼不存在")
					return false
				}
				let data = {
					zhuimoney: this.totalPrice,
					goods_list_ids: this.goods_list_ids.join(),
					order_goods_id: this.order_id,
					ly: 1, //如果是预约订單提交的时候,来源传2其他情况传1
					opentype: this.opentype,
					tbcode: this.appkey && this.opentype != -1 ? this.tbcode : '',
					tbmc: this.appkey && this.opentype != -1 ? this.tbmc : '',
					is_scan: 2,
					order_type: 4,
					paytype: val,
					order_attr: 1,
					yh_money: this.dkprice, //優惠金額
					rall_id: this.rall_ids, //優惠券id
				}
				this.issubmit = true
				uni.showLoading({
					mask: true,
					title: "請稍後"
				})
				let res1 = await this.http.request('/api/ordergoods/zhuiorderGoods', 'POST', data)
				uni.hideLoading()
				if (res1.code != 1) {
					this.issubmit = false
					httpRequest.toast(res.msg)
					return false
				}
				uni.showLoading({
					mask: true,
					title: "支付中"
				})
				if (this.dycode.substring(0, 2) == 'P1' || this.dycode.substring(0, 2) == 'P2') { //全支付
					let res2 = await httpRequest.request("/api/ordergoods/qxpayScan", "POST", {
						shop_id: uni.getStorageSync("shop_id"),
						id: this.order_id,
						pay_token: this.dycode
					})
					uni.hideLoading()
					if (res2.code == 1) {
						this.messagefk = {
							fkshow: true,
							paystatus: 1
						}
						setTimeout(() => {
							this.messagefk = {
								fkshow: false,
								paystatus: 1
							}
							uni.reLaunch({
								url: "/pages/workbench/newpos"
							})
						}, 1000)
					} else {
						this.issubmit = false
						this.dycode = ""
						this.dymodalshow = false
						this.dyinputfocus = false
						this.messagefk = {
							fkshow: true,
							paystatus: 2
						}
						setTimeout(() => {
							this.messagefk = {
								fkshow: false,
								paystatus: 2
							}
							this.dymodalshow = true
							this.dyinputfocus = true
						}, 1000)
					}
				}
				if (this.dycode.substring(0, 2) == 22) { //街口支付
					let res2 = await httpRequest.request("/api/ordergoods/jkoPayScan", "POST", {
						shop_id: uni.getStorageSync("shop_id"),
						id: this.order_id,
						CardToken: this.dycode,
						goods_list_ids: this.goods_list_ids.join()
					})
					uni.hideLoading()
					if (res2.code == 1) {
						this.messagefk = {
							fkshow: true,
							paystatus: 1
						}
						setTimeout(() => {
							this.messagefk = {
								fkshow: false,
								paystatus: 1
							}
							uni.reLaunch({
								url: "/pages/workbench/newpos"
							})
						}, 1000)
					} else {
						this.issubmit = false
						this.dycode = ""
						this.dymodalshow = false
						this.dyinputfocus = false
						this.messagefk = {
							fkshow: true,
							paystatus: 2
						}
						setTimeout(() => {
							this.messagefk = {
								fkshow: false,
								paystatus: 2
							}
							this.dymodalshow = true
							this.dyinputfocus = true
						}, 1000)
					}
				}
				if (this.dycode.substring(0, 2) == 38) { //linepay支付
					let res3 = await httpRequest.request("/api/ordergoods/linepayScan", "POST", {
						shop_id: uni.getStorageSync("shop_id"),
						id: this.order_id,
						oneTimeKey: this.dycode,
						goods_list_ids: this.goods_list_ids.join()
					})
					uni.hideLoading()
					if (res3.code == 1) {
						this.messagefk = {
							fkshow: true,
							paystatus: 1
						}
						setTimeout(() => {
							this.messagefk = {
								fkshow: false,
								paystatus: 1
							}
							uni.reLaunch({
								url: "/pages/workbench/newpos"
							})
						}, 1000)
					} else {
						this.issubmit = false
						this.dycode = ""
						this.dymodalshow = false
						this.dyinputfocus = false
						this.messagefk = {
							fkshow: true,
							paystatus: 2
						}
						setTimeout(() => {
							this.messagefk = {
								fkshow: false,
								paystatus: 2
							}
							this.dymodalshow = true
							this.dyinputfocus = true
						}, 1000)
					}
				}
			},
			shoukuanbtn() {
				let spunatdata = []
				for (let i = 0; i < this.spuList.length; i++) {
					let item = this.spuList[i]
					let num = 0
					item.list.forEach(value => {
						if (value.num != -0) {
							num = num + Number(value.num)
							spunatdata.push({
								spunatid: value.id,
								spunatname: value.name,
								num: value.num
							})
						}
					})
					if (item.fh == 1 && this.goodsdata.length) { //等於
						if (num != item.num_b) {
							this.http.toast(item.name + "的規格選擇" + item.num_b + "個")
							return false
						}
					}
					if (item.fh == 2 && this.goodsdata.length) { //大於等於
						if (num < item.num_b) {
							this.http.toast(item.name + "的規格至少選擇" + item.num_b + "個")
							return false
						}
					}
				}
				// 如果是后收款并且是内用情況下需要創建完訂單直接清空内容
				if (!this.editflag) { //非編輯模式
					if (this.shopInfo.sk_type == 2 && this.type == 2) {
						this.createOrder("清空")
					} else {
						if (this.appkey && this.is_pos_sdkfp == 0) {
							this.fpisshow = true
							this.fpinputfocus = true
						} else {
							this.show = true
						}
						this.createOrder()
					}
				} else { //編輯模式
					if (this.goodsdata.length == 0) {
						httpRequest.toast("請添加商品后操作")
						return false
					}
					if (this.shopInfo.sk_type == 2 && this.type == 2) {
						this.posAddGoods("清空")
					} else {
						this.show = true
						this.posAddGoods()
					}
				}
			},
			posAddGoods(val) {
				this.http.request('/api/ordergoods/posAddGoods', 'POST', {
					goodsdata: this.goodsdata,
					shop_id: uni.getStorageSync("shop_id"),
					id: this.order_id,
					zhuimoney: this.totalPrice,
				}).then(res => {
					if (res.code == 1) {
						if (val == "清空") {
							httpRequest.toast("提交成功")
							setTimeout(() => {
								uni.reLaunch({
									url: "/pages/workbench/newpos"
								})
							}, 1000)
						} else {
							this.goods_list_ids = res.data.goods_list_ids
							this.order_id = res.data.order_id
						}
					}
				})
			},
			createOrder(val) {
				let num = 0
				let cdbjhsf_data = []
				this.khlxlist.forEach(item => {
					cdbjhsf_data.push({
						name: item.name,
						num: item.num,
						price: item.price,
						total_price: item.num * item.price
					})
					num = item.num + num
				})
				let data = {
					shop_id: uni.getStorageSync("shop_id"),
					goodsdata: this.goodsdata,
					shoptable_id: this.shoptable_id, //使用id
					mobile: this.phone, //客户行动电话
					cdbjhsf_data,
					beizhu: '', //备注
					type: this.type,
					order_attr: val == '清空' ? 1 : 2,
					zhuimoney: this.totalPrice,
					fw_price: this.fwprice,
					table_price: this.reduceMainprice
				}
				if (val != "清空") {
					delete data.zhuimoney
				}
				this.http.request('/api/ordergoods/addOrder', 'POST', data).then(res => {
					if (res.code == 1) {
						if (val == "清空") {
							httpRequest.toast("提交成功")
							setTimeout(() => {
								uni.reLaunch({
									url: "/pages/workbench/newpos"
								})
							}, 1000)
						} else {
							this.goods_list_ids = res.data.goods_list_ids
							this.order_id = res.data.order_id
						}
					} else {
						this.http.toast(res.msg)
					}
				})
			},
			kaiqianx() {
				this.http.modal('提示', '是否開啓錢箱', true, (resp) => {
					if (resp) {
						this.http.request("/api/ordergoods/openqx", "POST", {
							shop_id: uni.getStorageSync("shop_id"),
						}).then(res => {
							httpRequest.toast(res.msg)
						})
					}
				})
			},
			numtapfp(item) {
				this.tbcode = this.tbcode + item
			},
			delnumfp() {
				let str = this.tbcode;
				let newStr = str.slice(0, -1);
				this.tbcode = newStr
				// 输出: Hello Worl
			},
			numtap(item) {
				if (Number(item) == 0 && this.zhifuje == "") {
					return false
				}
				this.zhifuje = this.zhifuje + item
			},
			delnum() {
				let str = this.zhifuje;
				let newStr = str.slice(0, -1);
				this.zhifuje = newStr
				// 输出: Hello Worl
			},
			delcarts(index) {
				this.goodsdata.splice(index, 1)
				if (!this.goodsdata.length) {
					this.listid = ""
				}
			},
			// 判断当前商品规格二是否是多选还是單选还是可选多个
			checkgger(item, value) {
				if (value.num == 1) {
					value.num = 0
					this.addgoodsspu()
					return false
				}
				if (item.num_b == 0) { //如果没有必选数量
					value.num = value.num == 1 ? 0 : 1
				} else { //如果存在必选数量
					item.fh == 1 ? '只能' : '至少'
					let checknum = 0
					item.list.forEach(current => {
						if (current.num == 1) {
							checknum = checknum + 1
						}
					})
					if (item.fh == 1) { //最多选几个
						if (checknum >= item.num_b) {
							httpRequest.toast(item.name + '的規格只能選' + item.num_b + '个')
							return false
						}
						value.num = value.num == 1 ? 0 : 1
					} else { //最少选几个
						value.num = value.num == 1 ? 0 : 1
					}
				}
				this.addgoodsspu()
			},
			addgoodsspu() {
				let spunatdata = []
				let price = 0
				for (let i = 0; i < this.spuList.length; i++) {
					let item = this.spuList[i]
					let num = 0
					item.list.forEach(value => {
						if (value.num) {
							num = num + Number(value.num)
							spunatdata.push({
								spunatid: value.id,
								spunatname: value.name,
								num: value.num
							})
							price = Number(price) + Number(value.money) * value.num
						}
					})
				}
				this.goodsdata[this.rightclassIndex].spunatdata = spunatdata
				price = (this.djprice * this.num + price)
				if (this.goodsdata.length) {
					this.goodsdata[this.rightclassIndex].price = price
				}
			},
			changegoods(id) {
				let spunatdata = []
				for (let i = 0; i < this.spuList.length; i++) {
					let item = this.spuList[i]
					let num = 0
					item.list.forEach(value => {
						if (value.num != -0) {
							num = num + Number(value.num)
							spunatdata.push({
								spunatid: value.id,
								spunatname: value.name,
								num: value.num
							})
						}
					})
					if (item.fh == 1 && this.goodsdata.length) { //等於
						if (num != item.num_b) {
							this.http.toast(item.name + "的規格選擇" + item.num_b + "個")
							return false
						}
					}
					if (item.fh == 2 && this.goodsdata.length) { //大於等於
						if (num < item.num_b) {
							this.http.toast(item.name + "的規格至少選擇" + item.num_b + "個")
							return false
						}
					}
				}
				this.getdetail(id)
			},
			getdetail(id, isedit, val) {
				this.listid = id
				uni.showLoading({
					mask: true,
					title: "請稍後"
				})
				this.http.request('/api/goods/deail', 'POST', {
					goods_id: this.listid
				}).then(res => {
					uni.hideLoading()
					if (res.code == 1) {
						let spuList = []
						res.data.goods_spu.forEach(item => {
							spuList.push({
								id: item.id,
								name: item.name,
								num_b: item.num_b,
								list: [],
								fh: item.fh,
								font_color:item.font_color
							})
						})
						res.data.goods_spunat.forEach(item => {
							this.$set(item, "num", 0)
							spuList.forEach(value => {
								if (item.goods_spu_id == value.id) {
									value.list.push(item)
								}
							})
						})
						spuList.forEach(item => {
							this.selectSpuNum.push({
								id: item.id,
								selectId: []
							})
						})
						this.spuList = spuList
						let sp_attr = []
						if (res.data.sp_attr) {
							res.data.sp_attr.split(",").forEach(item => {
								sp_attr.push({
									name: item,
									value: ""
								})
							})
						}
						this.sp_attr = sp_attr
						this.goodsInfo = res.data
						if (res.data.is_cl == 1) {
							this.clshow = true
						}
						this.djprice = res.data.goods_sale.length ? (res.data.goods_sale[0].sale_money.length ? res
							.data.goods_sale[0].sale_money[0].d_money : res.data.price) : res.data.price
						if (isedit !== true && val != 0) {
							this.goodsdata.unshift({
								shop_id: uni.getStorageSync('shop_id'), //店鋪id
								goods_id: this.goodsInfo.id, //商品id
								goods_name: this.goodsInfo.name, //商品名称
								logoimage: this.goodsInfo.logoimage, //商品logo
								wei: this.wei, //宽
								hei: this.hei, //高
								sp_attr: this.sp_attr,
								size: this.goodsInfo.unit, //單位
								spunatdata: [], //規格2
								num: this.num, //数量
								price: this.money, //价格
								d_price: this.djprice,
								addimage: this.addimage.join(), //上传的图片
								formulacount: this.formulaValue, //公式計算的值
								salename: this.goodsInfo.goods_sale.length ? this.goodsInfo.goods_sale[this
									.is_df].name : "", //销售类别名称
								type: 0, //0主商品 1子商品
								is_main: this.goodsInfo.is_main
							})
							this.num = 1
							this.rightclassIndex = 0
						} else {
							this.rightclassIndex = val
							if (this.goodsdata.length) {
								this.goodsdata[this.rightclassIndex].spunatdata.forEach(current => {
									this.spuList.forEach(cur => {
										cur.list.forEach(ite => {
											if (current.spunatid == ite.id) {
												ite.num = current.num
											}
										})
									})
								})
								this.num = this.goodsdata[this.rightclassIndex].num
							}

						}
					} else {
						this.http.toast(res.msg);
					}
				})
			},
			init(isPage, page) {
				let _this = this
				httpRequest.request('/api/goods/Goodslist', 'POST', {
					page: page || 1,
					limit: 30,
					shop_id: uni.getStorageSync("shop_id"),
					shopclassify_id: this.pid ? this.pid : "",
					name: this.name
				}).then(res => {
					if (this.hy_type == 6) {
						this.name = ""
					}
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottomt() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			classLableClick(item) { // 單击或双击
				if ((item.pid == 0 && item.is_haschild == 0) || (item.pid != 0 && item.is_haschild ==
						0)) {
					this.pid = item.id
				} else {
					this.pid = item.id
					this.getCateList()
				}
				this.topList.push(item)
				this.init()
			},
			back(item, index) { //点击顶部每一项返回上一分类
				this.pid = item.id
				if (this.pid == 0) {
					this.topList = [{
						name: "首頁",
						id: 0
					}]
					this.getCateList()
				} else {
					this.topList.splice(index + 1)
					this.getCateList()
				}
				this.init()
			},
			getCateList() { //分类列表
				let _this = this
				this.http.request('/api/shop/listClass', 'POST', {
					shop_id: uni.getStorageSync("shop_id"),
					id: this.pid
				}).then(res => {
					if (res.code == 1) {
						this.catedata = res.data
					} else {
						this.http.toast(res.msg)
					}
				})
			},
			backpage() {
				uni.navigateBack(1)
			},
			reset() {
				uni.reLaunch({
					url: "/pages/workbench/newpos"
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.androidpadding {
		// padding-top: 45rpx;
	}

	.lanlable {
		background-color: #31a3d6;
		border-radius: 5rpx;
		color: #fff;
		padding: 5rpx 10rpx;
		font-size: 30rpx;
		line-height: 26rpx;
		margin-right: 5rpx;
	}

	.itemcheckgoods {
		border: 1rpx solid #FF8505;
	}

	.itemboxcenter {
		// background-color: #d3e3fd;
		padding: 10rpx;
		border-radius: 20rpx;
		box-sizing: border-box;
		font-size: 28rpx;
		font-weight: bold;
		color: #333;
	}

	.nonumbox {
		width: 50rpx;
		height: 50rpx;
		background-color: #f0f0f0;
		color: #333;
	}

	.numbox {
		width: 50rpx;
		height: 50rpx;
		background-color: #fafafa;
		color: #fff;
		border-radius: 50%;
		background-color: #777;
	}

	.topnocheck {
		padding: 10rpx 30rpx;
		border: 1rpx solid #333;
		background-color: #fff;
		font-size: 28rpx;
		font-weight: bold;
		border-radius: 10rpx;
		color: #333;
	}

	.topcheck {
		padding: 10rpx 30rpx;
		border: 1rpx solid #e58701;
		background-color: #e58701;
		font-size: 28rpx;
		border-radius: 10rpx;
		font-weight: bold;
		color: #fff;
	}

	.qxbtn {
		background-color: #004FA3;
		color: #fff;
		font-size: 24rpx;
		font-weight: 900;
		padding: 10rpx 20rpx;
		border-radius: 10rpx;
		letter-spacing: 3rpx;
	}

	.leftclass {
		padding: 20rpx;
		border-bottom: 1rpx solid #f0f0f0;
		color: #777;
	}

	.itemgoods {
		border-radius: 8rpx;
		color: #FF8505;
		width: 150rpx;
		height: 150rpx;
		font-weight: bold;
		padding: 10rpx;
		box-sizing: border-box;

	}

	.goodsname {
		font-size: 32rpx;
		height: 96rpx;
		line-height: 32rpx;
	}
</style>
<style lang="scss" scoped>
	.margin_top15 {
		margin-top: 18rpx;
	}

	.baibtn {
		padding: 15rpx 20rpx;
	}

	.itemrighttab {
		padding: 18rpx 0;
		text-align: center;
		border-left: none;
		border-radius: 0 10rpx 10rpx 0;
	}

	.borderhui {
		border: 1rpx solid rgba(50, 60, 160, .1);
	}

	.tiebianarrow {
		height: 50rpx;
		background-color: #ffb800;
		width: 30rpx;
	}

	.main_size {
		font-size: 24rpx;
	}

	::v-deep .fpclass .u-modal__content {
		padding-bottom: 30rpx !important;
	}

	.itemboxfp {
		margin-top: 10rpx;
		width: 160rpx;
		height: 90rpx;
		border: 1rpx solid #000;
		border-radius: 10rpx;
		font-size: 40rpx;
		font-weight: bold;
		box-shadow: 0rpx 4rpx 16rpx 2rpx rgba(0, 0, 0, 0.16);
	}

	.pdl {
		border-bottom: 2rpx dashed #333;
	}

	.itembox {
		margin-top: 5rpx;
		width: 130rpx;
		height: 120rpx;
		border: 1rpx solid #000;
		border-radius: 10rpx;
		font-size: 50rpx;
		font-weight: bold;
		box-shadow: 0rpx 4rpx 16rpx 2rpx rgba(0, 0, 0, 0.16);
	}

	.itemboxbom {
		width: 110rpx;
		height: 40rpx;
		background-color: #94d5f5;
	}

	.itembox2 {
		margin-top: 15rpx;
		width: 150rpx;
		height: 120rpx;
		border: 1rpx solid #000;
		border-radius: 10rpx;
		font-size: 60rpx;
		font-weight: bold;
		box-shadow: 0rpx 4rpx 16rpx 2rpx rgba(0, 0, 0, 0.16);
	}

	.delitem {
		background-color: #013447 !important;
		color: #fff !important;
	}

	.payTypeClass {
		text-align: center;
		font-size: 28rpx;
		font-weight: bold;
		padding: 35rpx 0;
		width: 150rpx;
	}

	.qxbtn {
		background-color: #004FA3;
		color: #fff;
		font-size: 24rpx;
		font-weight: 900;
		padding: 10rpx 20rpx;
		border-radius: 10rpx;
		letter-spacing: 3rpx;
	}

	.sytsrk {
		font-size: 40rpx;
		font-weight: bold;
	}
</style>